fix(agent-core): count validation-rejected tool calls toward the repeat breaker - #2313
Merged
7Sageer merged 2 commits intoJul 28, 2026
Conversation
…at breaker Args-rejected calls returned before prepareToolExecution, so the breaker never counted them and the model could re-issue the same invalid call until maxSteps. Register them in finalizeToolResult so reminders fire at 3/5/8 and the turn force-stops at 12.
🦋 Changeset detectedLatest commit: 4e4f2d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d58e0e4a94
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Malformed JSON arguments normalize to {} on parse failure, which keyed
every malformed-but-different attempt identically and could force-stop a
turn whose calls were evolving rather than identical. Register skipped
calls on the raw arguments text when parsing failed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
No linked issue — explained below.
Problem
The repeat breaker only counts calls that reach
prepareToolExecution. Calls rejected by args validation return earlier and never register, so re-issuing the same invalid call gets no reminders and no stop — the turn only ends at maxSteps, burning a provider request per step.Reproduction (
test/agent/turn.test.ts): 12 identicalBashcalls missing the requiredcommand+ one trailing text response. Before: the turn consumes the 13th generation. After: it stops at exactly 12 with the fullnone → r1×2 → r2×3 → r3×4 → stopescalation chain.What changed
tool-dedup.ts: addregisterSkipped()for calls that bypassedprepareToolExecution(no-op when already registered).turn/index.ts: call it infinalizeToolResult, a hook every call passes through.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.